﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_Adminlogin : System.Web.UI.Page
{
    DataContext obj_datacontext = new DataContext();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void BtnLogin_Click(object sender, EventArgs e)
    {
        string query = "select* from tbl_adminmaster where username = '"+txtUsername.Text.ToString()+"'";
        DataTable dt = obj_datacontext.getdataTable(query);

        if (dt.Rows.Count > 0)
        {
            if (txtUsername.Text.ToString() == dt.Rows[0]["username"].ToString() && txtPassword.Text.ToString() == dt.Rows[0]["password"].ToString())
            {
                Session["adminid"] = Convert.ToInt32(dt.Rows[0]["i_autoid"].ToString());
                Response.Redirect("additems.aspx?id=" + Convert.ToInt32(dt.Rows[0]["i_autoid"].ToString()));


            }
            else
            {
                lblmessage.Text = "Invalid Username Password";
            }
        }
        else
        {
            lblmessage.Text = "Username Not exist";
        }
        
    }
}